home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 16 / AMIGAplus Sonderheft 16 (1998)(ICP)(DE)[!].iso / pd / anwendungen / xpk_source / libraries / fast / xpkfast.a < prev    next >
Text File  |  1998-08-27  |  5KB  |  156 lines

  1.     INCLUDE    AINCLUDE:IncDirs.i *sets all includedirs, needed for my ASM
  2.     INCLUDE    FAST/xpkLibFAST.i
  3.     include    "xpk/xpk.i"
  4.     include    "xpk/xpksub.i"
  5.     INCLUDE "exec/memory.i"
  6.  
  7.     INCLUDE    FAST/compress.a
  8.     INCLUDE    FAST/compress2.a
  9.     INCLUDE    FAST/decompress.a
  10.  
  11. _LVOXpksPackFree    EQU    -42
  12.  
  13. ;    XREF    compress_fast
  14. ;    XREF    compress_slow
  15. ;    XREF    decompress
  16.  
  17. PACKMEM_FAST    equ    $10000
  18. PACKMEM_SLOW    equ    $44000
  19.  
  20. UNPACKMEM    equ    0
  21.  
  22. _XpksPackChunk:
  23.     movem.l d2/a2/a3/a5/a6,-(a7)
  24.     move.l    a0,a5            ; xparams
  25.  
  26.     move.l    #PACKMEM_FAST,d0
  27.     lea.l    compress_fast(pc),a3
  28.  
  29.     moveq    #80,d1
  30.     cmp.l    xsp_Mode(a5),d1
  31.     bcs.s    IsFast
  32.     move.l    #PACKMEM_SLOW,d0
  33.     lea.l    compress_slow(pc),a3
  34. IsFast:
  35.     tst.l    xsp_Sub(a5)             ;Is there some memory allocated?
  36.     beq.s    AllocPackMem
  37.     cmp.l    xsp_Sub+4(a5),d0    ; Is the size right?
  38.     beq.s    packMemOK
  39.     jsr    _LVOXpksPackFree(a6)    ; Free currently allocated memory.
  40.  
  41. AllocPackMem:
  42.     move.l    d0,xsp_Sub+4(a5)
  43.     moveq    #XPKERR_NOMEM,d2
  44.     move.l    #MEMF_PUBLIC,d1
  45.     move.l    4.W,a6
  46.     jsr    _LVOAllocMem(A6)
  47.     move.l    d0,xsp_Sub(a5)
  48.     beq.s    endPackChunk
  49.  
  50. packMemOK:
  51.     moveq.l #XPKERR_EXPANSION,d2
  52.     move.l    xsp_InBuf(a5),a0        ;a0:=InBuf
  53.     move.l    xsp_OutBuf(a5),a1       ;a1:=OutBuf
  54.     move.l    xsp_Sub(a5),a2          ;a2:=Hash
  55.     move.l    xsp_InLen(a5),d0        ;d0:=InLen
  56.     moveq.l #90,d1
  57.     jsr    (a3)            ; call the compressor.
  58.     tst.l    d0
  59.     beq.s    endPackChunk
  60.     move.l    d0,xsp_OutLen(a5)       ;Fill in Final output length XpkSubParams
  61.     moveq    #XPKERR_OK,d2
  62. endPackChunk:
  63.     move.l    d2,d0
  64.     movem.l (sp)+,d2/a2/a3/a5/a6
  65.      rts
  66.  
  67. _XpksPackFree:
  68.     move.l    a6,-(a7)
  69.     move.l    xsp_Sub(a0),d1
  70.     beq.s    packFreeEnd
  71.     move.l    d1,a1
  72.     clr.l    xsp_Sub(a0)
  73.     move.l    xsp_Sub+4(a0),d0    ; currently allocated amount.
  74.     move.l    4.W,a6
  75.     clr.l    xsp_Sub+4(a0)
  76.     jsr    _LVOFreeMem(A6)
  77. packFreeEnd:
  78.     moveq    #XPKERR_OK,d0
  79.     move.l    (a7)+,a6
  80.     rts
  81.  
  82. _XpksUnpackChunk:
  83.     move.l    xsp_OutBuf(a0),a1
  84.     move.l    xsp_InLen(a0),d0
  85.     move.l    xsp_InBuf(a0),a0
  86.  
  87.     bsr    decompress
  88.     moveq.l #XPKERR_OK,d0
  89.     rts
  90.  
  91. _XpksPackerInfo:
  92.     lea    FastInfo(pc),a0
  93.     move.l    a0,d0
  94.     rts
  95.  
  96.  
  97. ; --- Static Data --------
  98. FastInfo:
  99.  dc.w    1        ;xi_XpkInfoVersion:Version number of this structure
  100.  dc.w    VERSION     ;xi_LibVersion     : The version of this sublibrary
  101.  dc.w    2        ;xi_MasterVersion: The required master lib version
  102.  dc.w    0        ;xi_ModesVersion : Longword align
  103.  dc.l    FastName    ;xi_Name     : Brief name of the packer
  104.  dc.l    LongName    ;xi_LongName     : Full name of the packer
  105.  dc.l    Description    ;xi_Description  : One line description of packer
  106.  dc.b    'FAST'          ;xi_ID           : ID the packer goes by (XPK format)
  107.             ;xi_Flags     : Defined below
  108.  dc.l    XPKIF_PK_CHUNK|XPKIF_UP_CHUNK|XPKIF_MODES
  109.  dc.l    $7FFFFFFF    ;xi_MaxPkInChunk : Max input chunk size for packing
  110.  dc.l    0        ;xi_MinPkInChunk : Min input chunk size for packing
  111.  dc.l    $10000        ;xi_DefPkInChunk : Default packing chunk size
  112.  dc.l    PackMsg     ;xi_PackMsg     : Packing message, present tense
  113.  dc.l    UnpackMsg    ;xi_UnpackMsg     : Unpacking message, present tense
  114.  dc.l    PackedMsg    ;xi_PackedMsg     : Packing message, past tense
  115.  dc.l    UnpackedMsg    ;xi_UnpackedMsg  : Unpacking message, past tense
  116.  dc.w    50        ;xi_DefMode     : Default mode number
  117.  dc.w    0        ;xi_Pad      : for future use
  118.  dc.l    Modes        ;xi_Modes     : Array of compression modes
  119.  dc.l    0,0,0,0,0,0    ;xi_Reserved,6*4 : Future expansion - set to zero
  120.  
  121. FastName:    dc.b    'fasTcinator',0
  122. LongName:    dc.b    'FAST alias WOOP or LZRW++',0
  123. Description:    dc.b    'LZ77-family, windowsize: 4095, no quotecount, 2 streams',0
  124. PackMsg:    dc.b    'tieing',0
  125. PackedMsg:    dc.b    'compressed',0
  126. UnpackMsg:    dc.b    'untieing',0
  127. UnpackedMsg:    dc.b    'decompressed',0
  128.     EVEN
  129.  
  130. Modes:
  131.  dc.l    Crawling    ;xm_Next      : Chain to next descriptor for ModeDesc list
  132.  dc.l    79        ;xm_Upto      : Maximum efficiency handled by this mode.
  133.             ;xm_Flags      : Defined below
  134.  dc.l    XPKMF_A3000SPEED
  135.  dc.l    PACKMEM_FAST     ;xm_PackMemory      : Extra memory required during packing
  136.  dc.l    UNPACKMEM    ;xm_UnpackMemory  : Extra memory during unpacking
  137.  dc.l    428        ;xm_PackSpeed      : Approx packing speed in K per second
  138.  dc.l    1055        ;xm_UnpackSpeed   : Approx unpacking speed in K per second
  139.  dc.w    327        ;xm_Ratio      : CF in 0.1% for AmigaVision executable
  140.  dc.w    0        ;xm_ChunkSize      : Desired chunk size in K (!!) for this mode
  141.  dc.b    'speedy',0,0,0,0 ;xm_Description,10:8 character mode description
  142.  
  143. Crawling:
  144.  dc.l    0        ;xm_Next      : Chain to next descriptor for ModeDesc list
  145.  dc.l    100        ;xm_Upto      : Maximum efficiency handled by this mode.
  146.             ;xm_Flags      : Defined below
  147.  dc.l    XPKMF_A3000SPEED
  148.  dc.l    PACKMEM_SLOW     ;xm_PackMemory      : Extra memory required during packing
  149.  dc.l    UNPACKMEM    ;xm_UnpackMemory  : Extra memory during unpacking
  150.  dc.l    70        ;xm_PackSpeed      : Approx packing speed in K per second
  151.  dc.l    1096        ;xm_UnpackSpeed   : Approx unpacking speed in K per second
  152.  dc.w    393        ;xm_Ratio      : CF in 0.1% for AmigaVision executable
  153.  dc.w    0        ;xm_ChunkSize      : Desired chunk size in K (!!) for this mode
  154.  dc.b    'crawling',0,0  ;xm_Description,10:8 character mode description
  155.     END
  156.